import { createRouter, createWebHistory } from 'vue-router'
import store from "@/util/store.js";

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [{
      path:"/login",
      name:"登录",
      component:()=>import("@/views/Login.vue")
    },{
      path:"/main",
      name:"布局",
      component:()=>import("@/layout/Layout.vue"),
      redirect:'/main/professionInfo',
      children:[
          {
              path:"professionAdd",
              name:"新增专家",
              component:()=>import("@/views/ProfessionAdd.vue")
          },
          {
              path:"professionInfo",
              name:"专家信息",
              component:()=>import("@/views/ProfessionInfo.vue")
          }
      ]
  }
  ],
})

router.beforeEach((to, from, next) => {
    store.commit("addTab", to)
    next()
})

export default router
